package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.Document;

public class ProductsWarehouseEditor extends JPanel
  implements EditorRecord
{
  public Object id;
  public Object prodid;
  public Object prodref;
  public Object prodname;
  public Object location;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JLabel jLabel5;
  private JTextField m_jMaximum;
  private JTextField m_jMinimum;
  private JTextField m_jQuantity;
  private JLabel m_jTitle;

  public ProductsWarehouseEditor(DirtyManager paramDirtyManager)
  {
    initComponents();
    this.m_jMinimum.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jMaximum.getDocument().addDocumentListener(paramDirtyManager);
  }

  public void writeValueEOF()
  {
    this.m_jTitle.setText(AppLocal.getIntString("label.recordeof"));
    this.id = null;
    this.prodid = null;
    this.prodref = null;
    this.prodname = null;
    this.location = null;
    this.m_jQuantity.setText(null);
    this.m_jMinimum.setText(null);
    this.m_jMaximum.setText(null);
    this.m_jMinimum.setEnabled(false);
    this.m_jMaximum.setEnabled(false);
  }

  public void writeValueInsert()
  {
    this.m_jTitle.setText(AppLocal.getIntString("label.recordnew"));
    this.id = null;
    this.prodid = null;
    this.prodref = null;
    this.prodname = null;
    this.location = null;
    this.m_jQuantity.setText(null);
    this.m_jMinimum.setText(null);
    this.m_jMaximum.setText(null);
    this.m_jMinimum.setEnabled(true);
    this.m_jMaximum.setEnabled(true);
  }

  public void writeValueEdit(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.id = arrayOfObject[0];
    this.prodid = arrayOfObject[1];
    this.prodref = arrayOfObject[2];
    this.prodname = arrayOfObject[3];
    this.location = arrayOfObject[4];
    this.m_jTitle.setText(Formats.STRING.formatValue(arrayOfObject[2]) + " - " + Formats.STRING.formatValue(arrayOfObject[3]));
    this.m_jQuantity.setText(Formats.DOUBLE.formatValue(arrayOfObject[7]));
    this.m_jMinimum.setText(Formats.DOUBLE.formatValue(arrayOfObject[5]));
    this.m_jMaximum.setText(Formats.DOUBLE.formatValue(arrayOfObject[6]));
    this.m_jMinimum.setEnabled(true);
    this.m_jMaximum.setEnabled(true);
  }

  public void writeValueDelete(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.id = arrayOfObject[0];
    this.prodid = arrayOfObject[1];
    this.prodref = arrayOfObject[2];
    this.prodname = arrayOfObject[3];
    this.location = arrayOfObject[4];
    this.m_jTitle.setText(Formats.STRING.formatValue(arrayOfObject[2]) + " - " + Formats.STRING.formatValue(arrayOfObject[3]));
    this.m_jQuantity.setText(Formats.DOUBLE.formatValue(arrayOfObject[7]));
    this.m_jMinimum.setText(Formats.DOUBLE.formatValue(arrayOfObject[5]));
    this.m_jMaximum.setText(Formats.DOUBLE.formatValue(arrayOfObject[6]));
    this.m_jMinimum.setEnabled(false);
    this.m_jMaximum.setEnabled(false);
  }

  public Object createValue()
    throws BasicException
  {
    return new Object[] { this.id, this.prodid, this.prodref, this.prodname, this.location, Formats.DOUBLE.parseValue(this.m_jMinimum.getText()), Formats.DOUBLE.parseValue(this.m_jMaximum.getText()), Formats.DOUBLE.parseValue(this.m_jQuantity.getText()) };
  }

  public Component getComponent()
  {
    return this;
  }

  public void refresh()
  {
  }

  private void initComponents()
  {
    this.m_jTitle = new JLabel();
    this.jLabel3 = new JLabel();
    this.m_jQuantity = new JTextField();
    this.jLabel4 = new JLabel();
    this.m_jMinimum = new JTextField();
    this.jLabel5 = new JLabel();
    this.m_jMaximum = new JTextField();
    setLayout(null);
    this.m_jTitle.setFont(new Font("SansSerif", 3, 18));
    add(this.m_jTitle);
    this.m_jTitle.setBounds(10, 10, 320, 30);
    this.jLabel3.setText(AppLocal.getIntString("label.units"));
    add(this.jLabel3);
    this.jLabel3.setBounds(10, 50, 150, 15);
    this.m_jQuantity.setHorizontalAlignment(4);
    this.m_jQuantity.setEnabled(false);
    add(this.m_jQuantity);
    this.m_jQuantity.setBounds(160, 50, 80, 19);
    this.jLabel4.setText(AppLocal.getIntString("label.minimum"));
    add(this.jLabel4);
    this.jLabel4.setBounds(10, 80, 150, 15);
    this.m_jMinimum.setHorizontalAlignment(4);
    add(this.m_jMinimum);
    this.m_jMinimum.setBounds(160, 80, 80, 19);
    this.jLabel5.setText(AppLocal.getIntString("label.maximum"));
    add(this.jLabel5);
    this.jLabel5.setBounds(10, 110, 150, 15);
    this.m_jMaximum.setHorizontalAlignment(4);
    add(this.m_jMaximum);
    this.m_jMaximum.setBounds(160, 110, 80, 19);
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.ProductsWarehouseEditor
 * JD-Core Version:    0.6.0
 */